home *** CD-ROM | disk | FTP | other *** search
-
- tell application "PsyScript"
- set fileHelper to load script file ("" & Psyscript base folder & "libraries:file.lib")
- set proteus to "
- tell application \"PsyScript\"
- activate
- begin experiment
- --load function libraries
- set fileHelper to load script file (\"\" & Psyscript base folder & \"libraries:file.lib\")
- set screen to load script file (\"\" & Psyscript base folder & \"libraries:screen.lib\")
- set stairCase to load script file (\"\" & Psyscript base folder & \"libraries:stairCase.lib\")
- --load stimuli
- tell fileHelper to initialize()
- tell fileHelper to createNewSubjectID()
-
- --load permanent stimuli if you need them
- -- load permanent stimulus \"fix\" as picture stimulus name
-
- --noticed any response keys
- set noticed of key \"Z\" to true
- --set a mapping or label for each key (if you do not want the default)
- set mapping of key \"Z\" to \"left\"
-
- --define your trial template (and any others you want (for instance a feedback trial)
- set trialString to \"!e + #100 !e !v 'hello' \"
-
- --load your stimuli from a file (assumed to be in a folder called \"" & fileHelper's pResourcesFolderName & "\" along side the script)
- set thefile to \"stimfilename\" --tab delimited file of stimuli
- --if it is not a full path, will assume it is in the default folder
- set stimList to readSpreadsheet(thefile) of fileHelper
- --or just include them here like this
- set stimList to {\"'hello'\", \"'goodbye'\"}
-
- repeat with aStim in stimList --while not completed
- do trial ITTtrialString given {aStim}
- if (subject response = \"left\") then
- set gradedResponse to 1
- else
- set gradedResponse to 0
- end if
- tell filehelper to writespreadsheet(aStim, gradedResponse)
- end repeat
-
- tell fileHelper to cleanup()
- end tell"
-
- activate
- set newName to choose file name with prompt "choose a location and new name for your experiment" default name "myExperiment"
- --try
- set f to open for access newName with write permission
- set eof f to 0
- write proteus to f
- close access f
- set placeholder to the offset of ":" in (the reverse of every character of (newName as string)) as string
- set theContainer to text 1 thru -(placeholder) of (newName as string)
- set folderName to "Picts"
- set whom to script editor as string
- set tCreator to file creator of (info for (script editor as string))
- set dlogStr to ""
- tell application "Finder"
- activate
- if exists folder named (fileHelper's pResourcesFolderName) of folder theContainer then
- set dlogStr to return & fileHelper's pResourcesFolderName & " folder already existed" & return
- else
- make folder at folder theContainer with properties {name:(fileHelper's pResourcesFolderName)}
- end if
- if exists folder named (fileHelper's pResultsFolderName) of folder theContainer then
- if (fileHelper's pResourcesFolderName) is in dlogStr then
- set dlogStr to return & "Both " & (fileHelper's pResourcesFolderName) & " and " & (fileHelper's pResultsFolderName) & " folders already existed" & return
- else
- set dlogStr to return & (fileHelper's pResultsFolderName) & " folder already existed" & return
- end if
- else
- make folder at folder theContainer with properties {name:(fileHelper's pResultsFolderName)}
- end if
- set creator type of newName to tCreator
- --set file type of newName to "osas"
- reveal newName
- if dlogStr = "" then
- display dialog "I just created a script and folders for " & (fileHelper's pResourcesFolderName) & " " & (fileHelper's pResultsFolderName) & " files"
- else
- display dialog "I just created a script" & dlogStr
- end if
- open newName
- end tell
- end tell
-
- (* on error m number n
- error m number n
- end try *)